
<h:form xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:ctg="http://www.crotouristguide.com/taglib"
	id="s1_form">
	<rich:panel styleClass="blue-panel">
		<ctg:status />
		<s:decorate id="wizar" template="/templates/wizard.xhtml">
			<ui:define name="step-title">#{messages['label.suggest.step.title.1']}</ui:define>
			<ui:define name="wizard-img">
				<!--<h:graphicImage value="/theme/default/images/logocro_test.gif"  alt="#{messages['label.image.alt']}"/>-->
			</ui:define>
			<ui:define name="step-tip">#{messages['label.suggest.step.tip.1']}</ui:define>
			<ui:define name="step-form">
				<a:region renderRegionOnly="true">
					<h:panelGrid columns="2">
						<s:decorate id="kategorijaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.category']} (#{messages['label.stars']})</ui:define>
							<h:selectOneMenu id="kategorija" styleClass="field"
								value="#{objektSuggest.kategorija}">
								<s:selectItems id="kategorijeObjekta"
									value="#{objektSuggest.kategorije}" var="k"
									label="#{k.brojZvjezdica}" />
								<s:convertEntity />
							</h:selectOneMenu>
						</s:decorate>
						<s:decorate id="imeObjektaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.objekt.name']}</ui:define>
							<h:inputText id="nazivObjekta" styleClass="field" required="true"
								value="#{objektSuggest.objekt.naziv}">
							</h:inputText>
						</s:decorate>
						<s:decorate id="tipObjektaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.objekt.input.type']}</ui:define>
							<h:selectOneMenu id="tipObjekta" styleClass="field"
								value="#{objektSuggest.tipObjekta}">
								<s:selectItems id="tipoviObjekta"
									value="#{objektSuggest.tipoviObjekta}" var="to"
									label="#{to.naziv}" />
								<s:convertEntity />
							</h:selectOneMenu>
						</s:decorate>
						<s:decorate id="urlObjektaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.objekt.url']}</ui:define>
							<h:inputText id="urlObjekta" styleClass="field"
								value="#{objektSuggest.objekt.siteUrl}">
							</h:inputText>
						</s:decorate>

						<s:decorate id="zupanijaMjestaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.objekt.county']}</ui:define>
							<h:selectOneMenu id="zupanijaMjesta" styleClass="field"
								required="true"
								valueChangeListener="#{objektSuggest.zupanijaObjektaSelected}"
								value="#{objektSuggest.zupanija}" immediate="true">
								<s:selectItems id="zupanije"
									value="#{objektSuggest.zupanijeObjekta}" var="z"
									label="#{z.naziv}"
									noSelectionLabel="#{messages['label.suggest.selectvalue']}" />
								<s:convertEntity />
								<a:support event="onchange" disableDefault="true"
									reRender="zupanijaMjestaDecoration,postaMjestaDecoration,mjestoObjektaDecoration" />
							</h:selectOneMenu>
						</s:decorate>
						<br />
						<s:decorate id="postaMjestaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.posta.naziv']}</ui:define>
							<h:selectOneMenu id="postaMjesta" value="#{objektSuggest.posta}"
								styleClass="field"
								valueChangeListener="#{objektSuggest.postaObjektaSelected}"
								required="true" immediate="true">
								<s:selectItems id="poste" binding="#{soComponents.posteObjekta}"
									var="p" label="#{p.naziv}"
									noSelectionLabel="#{messages['label.suggest.selectvalue']}" />
								<s:convertEntity />
								<a:support event="onchange"
									reRender="postaMjestaDecoration,mjestoObjektaDecoration" />
							</h:selectOneMenu>
						</s:decorate>
						<h:outputText value="" />
						<s:decorate id="mjestoObjektaDecoration"
							template="/templates/edit.xhtml">
							<ui:define name="label">#{messages['label.mjesto.naziv']}</ui:define>
							<h:selectOneMenu id="mjestoObjekta" styleClass="field"
								value="#{objektSuggest.mjesto}" required="true">
								<s:selectItems id="mjesta"
									value="#{objektSuggest.mjestaObjekta}" var="m"
									label="#{m.naziv}"
									noSelectionLabel="#{messages['label.suggest.selectvalue']}" />
								<s:convertEntity />
								<!-- <a:support event="onchange" reRender="mjestoObjektaDecoration" />-->
							</h:selectOneMenu>
						</s:decorate>
						<h:outputText value="" />
					</h:panelGrid>
				</a:region>
				<br />
				<h:outputText styleClass="title-14er"
					value="#{messages['label.map']}" />
				<br />
				<span class="note"><h:outputText
					value="#{messages['label.suggest.step.tip.objekt.map']}" /></span>
				<ctg:googleMaps gmapVar="map" width="650"
					height="450"
					largeMapControl="true" mapTypeControl="true" scaleControl="true"
					overviewMapControl="true" lat="#{objektSuggest.latituda}"
					lng="#{objektSuggest.longituda}" zoom="#{objektSuggest.zoom}"/>
				<script type="text/javascript">
					function loadMap(map){	
						GEvent.addListener(map, "zoomend", function(){
							document.getElementById('includer:s1_form:wizar:zoom').value=map.getZoom();
						});

						var center = new GLatLng(#{objektSuggest.latituda}, #{objektSuggest.longituda});
						var marker = new GMarker(center, {draggable: true});
						GEvent.addListener(marker, "dragend", function(){
					   		document.getElementById('includer:s1_form:wizar:latitude').value=marker.getPoint().lat(); 
					   		document.getElementById('includer:s1_form:wizar:longitude').value=marker.getPoint().lng(); 	
						});
						map.addOverlay(marker);							
					}								
				</script>

				<h:inputHidden value="#{objektSuggest.zoom}" id="zoom"/>
				<h:inputHidden value="#{objektSuggest.latituda}" id="latitude"/>
				<h:inputHidden value="#{objektSuggest.longituda}" id="longitude"/>			
			</ui:define>
			<ui:define name="buttn-cancel">
				<h:commandButton styleClass="submit"
					value="#{messages['label.objekt.input.button.update']}"
					action="#{objektSuggest.zapisiObjekt}" rendered="#{objektSuggest.editMode}"/>	
				<ctg:nbsp/>
				<a:commandButton value="#{messages['label.input.cancel']}"
					action="end" immediate="true" />
			</ui:define>
			<ui:define name="buttn-prev">
			</ui:define>
			<ui:define name="buttn-next">
				<h:commandButton value="#{messages['label.input.next']}"
					action="#{objektSuggest.nextStep}">
				</h:commandButton>								
			</ui:define>
			<ui:define name="step-entered-data"></ui:define>
		</s:decorate>
	</rich:panel>
</h:form>